package com.acc.mobileappr.constant;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * Application Constant
 */
public class AppConstant {


    public static final String APP_PROPERTIES = "Application";
    public static final String PROP_DEFAULT_PASSWORD = "app.default.password";

    //Persistence unit constant
    public static final String PERSISTENCE_UNIT_MAREX = "MarexPU";

    //login error constant
    public static final String LOGIN_FAIL_NOUSER = "FAIL_USER_NOT_FOUND";
    public static final String LOGIN_FAIL_WRONGPASSWORD = "FAIL_WRONG_PASSWORD";
    public static final String LOGIN_FAIL_INTERNAL_ERROR = "FAIL_INTERNAL_ERROR";
    public static final String LOGIN_OK = "OK";

    //approval error constant
    public static final String APPROVE_OK = "OK";
    public static final String APPROVE_NO_REQUEST_EXIST = "FAIL_NO_REQUEST_EXIST";
    public static final String APPROVE_NO_ACTION_EXIST = "FAIL_NO_ACTION_EXIST";

    //Property keys
    public static final String PROP_DEVICE_PORT = "device.port";
    public static final String PROP_MDS_HOST = "mds.host";
    public static final String PROP_MDS_PORT = "mds.port";

    public static final String PROP_APPLICATION_IP = "app.ip";
    public static final String PROP_APPLICATION_PATH = "app.path";
    public static final String PROP_APPLICATION_PORT = "app.port";


    public static final String PROP_MAX_RETRY = "max.retry";

    public static final String PROP_LN_IP = "ln.ip";
    public static final String PROP_LN_SECURITY = "ln.security";
    public static final String PROP_LN_ID = "ln.id";
    public static final String PROP_LN_PWD = "ln.pwd";


    /**
     * This method is used by the sample push initiator to retrieve String values from mobileappr-push-initiator.properties.
     *
     * @param property the property to retrieve the value for
     * @return the property's value
     */
    public static String getProperty(String property) {
        ResourceBundle properties = ResourceBundle.getBundle(APP_PROPERTIES, Locale.getDefault());
        return properties.getString(property);
    }

    /**
     * This method is used by the sample push initiator to retrieve Integer values from mobileappr-push-initiator.properties.
     * @param property the property to retrieve the value for
     * @return the property's value
     */
    public static Integer getIntegerProperty(String property) {
        String value = getProperty(property);
        return Integer.valueOf(value);
    }

    /**
     * This method is used by the sample push initiator to retrieve Boolean values from mobileappr-push-initiator.properties.
     * @param property the property to retrieve the value for
     * @return the property's value
     */
    public static Boolean getBooleanProperty(String property) {
        String value = getProperty(property);
        return Boolean.valueOf(value);
    }

    /**
     * get default password
     * @return
     */
    public static String getDefaultPassword() {
        String value = getProperty(PROP_DEFAULT_PASSWORD);
        return value;
    }

}
